大家安安
突然發現有人關注
但是~
前面的坑還沒有補好
後面很難寫
不過這篇我預計會寫"算利息"因為"人生第一次忘記繳錢"
還好只過了一天..沒被罰錢
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BA993265_2
{
class Program
{
static void Main(string[] args)
        {
            {
                string[] monthStr = new string[] { "一", "二", "三", "四", "五" };
                int month = 0;
                double loan = 0.0, pay = 0.0, total = 0.0;
                double interest = 0.0;//利息
                double interestTotal = 0.0;
                double tax = 0.18;//年利率
                double tot_interest = 0.0;//利息總額
                while (true)
                {
                    Console.Write("\n請輸入您向銀行的借款金額:");
                    loan = Convert.ToDouble(Console.ReadLine());//將輸入的資料轉成整數
                    total = loan;
                    Console.Write("請輸入您每月還款的金額");
                    pay = Convert.ToDouble(Console.ReadLine());//將輸入的資料轉整數
                    if (pay > loan)
                    {
                        Console.Write("\n每月還款不能大於 借款!\n");
                        continue;
                    }
                    break;
                }
                while (loan > 0)
                {
                    interest = (loan * tax) / 12;//每月應還的利息
                    if ( loan - pay > 0 )
                    {
                        loan -= pay;                        
                        loan += interest;
                    }
                    month++;                    
                    
                    Console.WriteLine("第{0}個月底,利息等於{1:C},尚欠{2:C}", monthStr[month-1], interest, loan);
                    if (loan - pay < 0)
                    {
                        interest = loan * tax / 12;
                        loan += interest;
                        month++;
                        Console.WriteLine("第{0}個月底,利息等於{1:C},最後還款{2:C}", monthStr[month - 1], interest, loan);
                        loan = 0;                        
                    }
                    interestTotal += interest;
                }
                Console.WriteLine("您借{0},還了{1}個月,利息共還{2:C}.\n\n", total, month, interestTotal);
                Console.Read();
            }
        }
DEAR ALL 我們明天見 